package com.zrq.gencode.cfg;

import org.apache.commons.lang.StringUtils;

import com.zrq.gencode.exception.jdbc.JdbcNullDriverException;
import com.zrq.gencode.exception.jdbc.JdbcNullPassWordException;
import com.zrq.gencode.exception.jdbc.JdbcNullUrlException;
import com.zrq.gencode.exception.jdbc.JdbcNullUserNameException;
import com.zrq.gencode.properties.Propertiez;

/**
 * @author zhong
 * @date  2020年1月8日
 */
public class JdbcCfg {

	private static final String JDBCDRIVER = "gencode.jdbc.driver";
	private static final String JDBCURL = "gencode.jdbc.url";
	private static final String JDBCUSERNAME = "gencode.jdbc.userName";
	private static final String JDBCPASSWORD = "gencode.jdbc.passWord";

	public static String getJdbcDriver(){
		String jdbcDriver = Propertiez.properties.getProperty(JDBCDRIVER, "com.mysql.cj.jdbc.Driver");
		if (StringUtils.isBlank(jdbcDriver)) {
			throw new JdbcNullDriverException();
		}
		return jdbcDriver;
	}

	public static String getJdbcurl() {
		String jdbcurl = Propertiez.properties.getProperty(JDBCURL);
		if (StringUtils.isBlank(jdbcurl)) {
			throw new JdbcNullUrlException();
		}
		return jdbcurl;
	}

	public static String getJdbcusername() {
		String jdbcusername = Propertiez.properties.getProperty(JDBCUSERNAME);
		if (StringUtils.isBlank(jdbcusername)) {
			throw new JdbcNullUserNameException();
		}
		return jdbcusername;
	}

	public static String getJdbcpassword() {
		String jdbcpassword = Propertiez.properties.getProperty(JDBCPASSWORD);
		if (StringUtils.isBlank(jdbcpassword)) {
			throw new JdbcNullPassWordException();
		}
		return jdbcpassword;
	}
}